package com.huluobo.high3videoproject.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.huluobo.high3videoproject.R;
import com.huluobo.high3videoproject.mvp.live.view.LiveActivity;
import com.huluobo.high3videoproject.mvp.login.view.LoginActivity;
import com.huluobo.high3videoproject.startLive.view.StartLiveActivity;
import com.hyphenate.chat.EMClient;

public class LiveFragment extends Fragment {

    private Button open, openDanmaku, logout;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_live, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        open = view.findViewById(R.id.open);
        open.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), StartLiveActivity.class);
                getActivity().startActivity(intent);
            }
        });
        openDanmaku = view.findViewById(R.id.openDanmaku);
        openDanmaku.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), LiveActivity.class);
                getActivity().startActivity(intent);
            }
        });

        logout = view.findViewById(R.id.logout);
        logout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EMClient.getInstance().logout(true);
                Intent intent = new Intent(getActivity(), LoginActivity.class);
                getActivity().startActivity(intent);
                getActivity().finish();
            }
        });
    }
}
